package com.fare.taluo.application.impl.fetl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.fetl.IOfficialPlusDayApplication;
import com.fare.taluo.fetl.domain.entity.OfficialPlusDayEntity;
import com.fare.taluo.vo.fetl.OfficialPlusDayVO;

@Transactional
@Service("officialPlusDayApplication")
public class OfficialPlusDayApplicationImpl implements IOfficialPlusDayApplication {



	@Override
	public List<OfficialPlusDayVO> findByCondition(Date reportDate,
			String fromCity, String toCity, String channel, String hbaseKey) {
		List<OfficialPlusDayVO> listVo=new ArrayList<OfficialPlusDayVO>();
		OfficialPlusDayEntity entity =new OfficialPlusDayEntity();
		List<OfficialPlusDayEntity> listEntity =entity.findByCondition(reportDate, fromCity, toCity, channel, hbaseKey);
		if(null!=listEntity && listEntity.size()>0){
			for(OfficialPlusDayEntity en :listEntity){
				OfficialPlusDayVO vo =this.entityToVO(en);
				if(null!=vo && null!=vo.getHbaseKey()){
					listVo.add(vo);
				}
			}
		}
		return listVo;
	}
	
	private OfficialPlusDayEntity VoToEntity(OfficialPlusDayVO vo){
		OfficialPlusDayEntity entity =new OfficialPlusDayEntity();
		entity.setId(vo.getId());
		entity.setChannel(vo.getChannel());
		entity.setCreateTime(vo.getCreateTime());
		entity.setFromCity(vo.getFromCity());
		entity.setFromCityName(vo.getFromCityName());
		entity.setHbaseKey(vo.getHbaseKey());
		entity.setReportDate(vo.getReportDate());
		entity.setThreshold03(vo.getThreshold03());
		entity.setThreshold06(vo.getThreshold06());
		entity.setToCity(vo.getToCity());
		entity.setToCityName(vo.getToCityName());
		return entity;
	}
	
	private OfficialPlusDayVO entityToVO(OfficialPlusDayEntity entity){
		OfficialPlusDayVO vo =new OfficialPlusDayVO();
		vo.setId(entity.getId());
		vo.setChannel(entity.getChannel());
		vo.setCreateTime(entity.getCreateTime());
		vo.setFromCity(entity.getFromCity());
		vo.setFromCityName(entity.getFromCityName());
		vo.setHbaseKey(entity.getHbaseKey());
		vo.setReportDate(entity.getReportDate());
		vo.setThreshold03(entity.getThreshold03());
		vo.setThreshold06(entity.getThreshold06());
		vo.setToCity(entity.getToCity());
		vo.setToCityName(entity.getToCityName());
		return vo;
	}
}
